package com.yishun.springboot.web;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yinquan.util.ResultUtils;
import com.yishun.springboot.service.GongWuSuTspDistrictlevelService;

@RestController
@RequestMapping("/Districtlevel")
/**
 * 将数据推送给区局工务署
 *
 * @author GA
 *
 */
public class GongWuSuTspDistrictlevelController {

	@Autowired
	GongWuSuTspDistrictlevelService gongWuSuTspDistrictlevelService;

	@RequestMapping("/uploadCityGwsTspDetailed")
	public String uploadCityGwsTspDetailed(@RequestBody JSONObject paramJsonObject) {
		Map<String, Object> paramMap = new HashMap<String, Object>();

		String deviceCode = paramJsonObject.getString("deviceCode");
		String projectName = paramJsonObject.getString("projectName");
		String apiKey = paramJsonObject.getString("apiKey");
		String projectCode = paramJsonObject.getString("projectCode");
		String engCode = paramJsonObject.getString("engCode");
		String installCompany = paramJsonObject.getString("installCompany");
		String version = paramJsonObject.getString("version");
		if (StringUtils.isEmpty(apiKey) || StringUtils.isEmpty(projectCode) || StringUtils.isEmpty(engCode)
				|| StringUtils.isEmpty(deviceCode) || StringUtils.isEmpty(projectName)
				|| StringUtils.isEmpty(installCompany) || StringUtils.isEmpty(version)) {
			return JSONObject.toJSONString(ResultUtils.jsonFail(400), SerializerFeature.WriteMapNullValue);
		}
		paramMap.put("installCompany", installCompany);
		paramMap.put("apiKey", apiKey);
		paramMap.put("deviceCode", deviceCode);
		paramMap.put("projectName", projectName);
		paramMap.put("projectCode", projectCode);
		paramMap.put("engCode", engCode);
		paramMap.put("version", version);
		String res = gongWuSuTspDistrictlevelService.updateGongWuShuTspDetailedData(engCode, projectCode, apiKey,
				deviceCode, projectName, paramMap);

		return res;
	}

}
